<?php
	
	//后台产品分类的模型
	class CategoryModel extends RelationModel{
		
		
		//定义映射字段（在表单中隐藏真正的数据表字段）
		protected $_map=array(
			'cate_id'     =>'c_id',
			'cate_name'   =>'c_name',
			'cate_desc'   =>'c_desc',
			'cate_sort'	  =>'c_sort',
			'cate_parent_id' =>'c_parent_id'
		);
		
		//定义字段（让I/O流减少加载消耗）
		protected $fields=array(
				'c_id',
				'c_name',
				'c_desc',
				'c_sort',
				'c_parent_id',
				'_pk'      => 'c_id',
				'_autoinc' =>true
	);
		
		//关联模型(关联删除)
		protected $_link=array(
				'Category' =>array(
						'mapping_type'  => BELONGS_TO,
						'mapping_name'  => 'cate',
						'mapping_fields'=> 'c_name',
						'class_name'    =>'Category',
						'parent_key'    =>'c_parent_id'
				),
				'Goods' =>array(
						'mapping_type'  => HAS_MANY,
						'mapping_name'  => 'goods',
						'mapping_fields'=> 'g_name',
						'class_name'    =>'Goods',
						'foreign_key'   =>'c_id'
				)
				
		);
		
	}